|
|
|
|
|
|
|
from bouncing from one test to another without any plan. You should test the application in a logical sequence so that after you have tested a portion of the code, you can be confident that it will work. |
|
|
|
|
|
|
|
|
Finding where a problem happened in a computer program isn't as easy as it sounds. The fact that you are trying to accomplish it in a Windows environment makes it that much more difficult. Because Visual Basic stops the execution of the application when a problem occurs, this enables you to at least identify the section of code to look at. Many times, Visual Basic displays an error message like the one shown in Figure 18.1 that tells you the error. However, it does not tell you where it happened or how to fix it. |
|
|
|
|
|
|
|
|
Figure 18.1.
A typical error message from Visual Basic
during the testing process. |
|
|
|
|
|
|
|
|
Even more confusing is that the actual problem or error might have occurred earlier, in an entirely different area of the program, but, has manifested at this time. What this means in English, is that you will have to work backwards from the point of the problem to find the real culprit, almost like solving a crime. You have clues, but you have to look carefully for the guilty line of code. |
|
|
|
|
|
|
|
|
Luckily for you, Visual Basic provides some very good tools to assist you when testing and debugging your application. These tools enable you to look at how the application logic flows from one routine to another. In addition, it enables you to observe how variables and property settings change during the execution of the application. What you're really doing is lifting the hood of your application and looking at the engine. |
|
|
|
|
|
|
|
|
The testing and debugging process can be made much simpler by simply adhering to the following concepts and techniques: |
|
|
|
|
|
|
|
|
Use the Option Explicit statement to prevent misspelled variable and object names. |
|
|
|
|
|
|
|
|
Include well-designed error-handling routines to trap many of the problems that can occur. |
|
|
|
|
|